/** \file Audio.h
    \author belot.nicolas
    Generic Interface for AudioOutput
    */


#ifndef AUDIO_H
#define AUDIO_H 1

#include "Buffer.h"
#include <string>
namespace libtrckr {
class Audio {
/** \class libtrckr::Audio
    \brief Generic Interface for Audio Output
*/
	public :
	enum audio_state_t {INVALID, CLOSE, OPEN,UNAVAIL};

	virtual ~Audio();
	/** get the number of channel */
	virtual int channels() const;
	/**set the number of channels */
	virtual void channels( int);
	/** get the birate */
	virtual int bitrate() const;
	/** set the bitrate */
	virtual void bitrate(int);

	/** Open the output */
	virtual void open()=0;
	/** output state of the Audio */
	virtual audio_state_t state()=0;
	/** Close the output */
	virtual void close()=0;

	/** Append data to the output
	*/
	virtual int append(Buffer b)=0;	
	/** Set parameters depend of the derivated class
	\param name name of the parameter
	\param value value of the parameter
	*/
	virtual void param(std::string, std::string)=0;	
	/**	\overload libtrckr::Audio::param(std::string,double)
	*/
	virtual void param(std::string, double)=0;
	/**	\overload libtrckr::Audio::param(std::string,int)
	*/
	virtual void param(std::string, int)=0;

	/// copy internal buffer into data. Used by derivated class.
	int getFrames(int nbframes, double* data );

	protected :
	static double *sbuffer;
	static bool *lock;
	static 	int *start;
	static	int *end;
	static	int *size;
	static int *capacity;

	/** append data in the internal ring buffer.
		\param b buffer to append
	*/
	void copy(Buffer&);
	/** \overload libtrckr::Audio::copy(double*,int)
	*/
	void copy(double*, int);

	private:
		unsigned short int _channels;
		uint _bitrate;

};

}
#endif

